package com.sdp.irrigation.db.irrigation_eq.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdp.irrigation.db.irrigation_eq.mapper.IrrigationEqMapper;
import com.sdp.irrigation.db.irrigation_eq.service.IIrrigationEqService;
import com.sdp.irrigation.entity.IrrigationEq;

/**
 * <p>
 * 设备台账 服务实现类
 * </p>
 *
 * @author zsp
 * @since 2024-12-14
 */
@Service
public class IrrigationEqServiceImpl extends ServiceImpl<IrrigationEqMapper, IrrigationEq> implements IIrrigationEqService {

	@Override
	public void updateEqUseStateByEqNo(String eqNo,String eqUseState) {
		LambdaUpdateWrapper<IrrigationEq> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
		lambdaUpdateWrapper.set(IrrigationEq::getEqUseState, eqUseState);
		lambdaUpdateWrapper.eq(IrrigationEq::getEqNo, eqNo);
		update(lambdaUpdateWrapper);
	}

	@Override
	public void updateEqRepairStatusByEqNo(String eqNo, String eqRepairState) {
		LambdaUpdateWrapper<IrrigationEq> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
		lambdaUpdateWrapper.set(IrrigationEq::getEqRepairStatus, eqRepairState);
		lambdaUpdateWrapper.eq(IrrigationEq::getEqNo, eqNo);
		update(lambdaUpdateWrapper);
		
	}

	@Override
	public IrrigationEq queryEqByEqNo(String eqNo) {
		LambdaQueryWrapper<IrrigationEq> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(IrrigationEq::getEqNo, eqNo);
		return getOne(lambdaQueryWrapper,false);
	}

}
